steam_ugc_download

语法:

steam_ugc_download(ugc_handle, dest_filename);


参数 描述
ugc_handle The unique handle for the preview to be downloaded.
dest_filename The file name to save the preview with.


Returns: Async ID


描述

With this function you can download a preview image for any given UGC item. The ugc_handle is the unique identifying value for the image (which you can get using the function steam_ugc_send_query()), and the destination filename is the name (and local path within the Steam sandbox) that you wish to give the image file when the download is complete.

When using this function it will trigger an Steam Asynchronous event to report the details of the image file requested containing the following key/value pairs in the async_load ds_map:

  1. "id" - The async ID returned by the calling function

  2. "result" - 操作的结果(实际值)。这将是 GML 常量 ugc_result_success 或其他一些实数。So you should check for this constant to ensure that the call was successful, and if otherwise somthing has not worked correctly. 返回的其余可能值显示为 Steam “EResult” 值的结果,你应该在 SDK 头文件 steamclientpublic.h 中看到所有 89 个可能值。

  3. "event_type" - This key will hold the value "ugc_download"

  4. "original_filename" - This key holds the original name of the image file on the server (a string)

  5. "dest_filename" - This key holds the image file name you passed in (a string)

  6. "ugc_handle" - This key holds the ugc_handle value that you passed in to the calling function


Extended 举例:

In this example we first call the function and store the async ID value in a variable:

steam_get = steam_ugc_download(steam_handle, "\UGC\Preview_file.png");

This would then send off a file request to the Steam API, generating an async event which we would deal with as follows:

var event_id = async_load[?"id"];
if event_id == steam_get
   {
   var type = async_load[?"event_type"];
   if type == "ugc_download"
      {
      sprite_delete(preview_sprite);       preview_sprite = sprite_add(async_load[?"dest_filename"], 0, false, false, 0, 0);
      }
   }

The above code checks the event type and then creates a sprite from the downloaded image.